#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/mod_devicetable.h>

#define HELLO_DBG
#ifdef HELLO_DBG
#define hello_dbg(fmt, ...) printk("[%s][%d]" fmt "\r\n", __func__, __LINE__, ##__VA_ARGS__)
#else
#define hello_dbg(fmt, ...)
#endif

#define MODULE_NAME "hello_platform"

static int hello_platform_probe(struct platform_device *dev)
{
    hello_dbg("");

    return 0;
}

static int hello_platform_remove(struct platform_device *)
{
    hello_dbg("");

    return 0;
}

static const struct of_device_id hello_platform_table[] = {
    {.compatible = "hello,platform"},
    {},
};

static struct platform_driver dri = {
    .probe = hello_platform_probe,
    .remove = hello_platform_remove,
    .driver = {
        .name = MODULE_NAME,
        .of_match_table = hello_platform_table,
    },
};

static int __init hello_platform_init(void)
{
    int ret;

    hello_dbg("");

    ret = platform_driver_register(&dri);
    if (ret)
    {
        hello_dbg("platform_driver_register err:%d", ret);
        return ret;
    }

    return 0;
}

static void __exit hello_platform_exit(void)
{
    platform_driver_unregister(&dri);

    hello_dbg("");
}

module_init(hello_platform_init);

module_exit(hello_platform_exit);

MODULE_AUTHOR("ljq");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("test platform driver");
